<?php
class ProflieAction extends GlobalAction{
    public function index(){
    	$this->proflie_list();
    }
    public function proflie_list(){
    	$proflie = M('proflie');
    	$proflie = $proflie->order('sorting asc,proflie_id asc')->findall();
    	$this->assign('proflie',$proflie);
    	$this->GlobalName();
		$this->display('list');
    }
    public function proflie_search(){
        $search['title'] = array('like','%'.$_POST['search'].'%');
        $search['e_title'] = array('like','%'.$_POST['search'].'%');
        $search['contents'] = array('like','%'.$_POST['search'].'%');
        $search['e_contents'] = array('like','%'.$_POST['search'].'%');
        $search['_logic'] = 'or';
    	$proflie = M('proflie');
    	$proflie = $proflie->where($search)->order('sorting asc,proflie_id asc')->findall();
    	$this->assign('proflie',$proflie);
    	$this->GlobalName();
		$this->display('list');
    }
    public function add(){
    	$this->GlobalName();
		$this->display();
    }
    public function proflie_news_get(){
    	$proflie = M('proflie');
    	$proflie->create();
    	if ($proflie->add()) {
    		$this->get_alert('新增成功');
    	};
    }
    
    public function edit(){
    	$pid = $_GET['pid'];
    	$proflie = M('proflie');
    	$proflie = $proflie->where('proflie_id = '.$pid)->findall();
    	$this->assign('proflie',$proflie);
    	$this->GlobalName();
		$this->display();
    }
    public function proflie_edit_get(){
    	$proflie = M('proflie');
    	$proflie->create();
    	if ($proflie->save()) {
    		$this->get_alert('修改成功');
    	};
    }
    
    
    
    public function proflie_delete(){
    	$proflie = M('proflie');
    	$del = $_POST['del'];
    	$delete = $del[0];
    	for ($i=1;$i < count($del);$i++){
    		$delete = $delete.','.$del[$i];
    	}
    	if ($proflie->delete($delete)) {
    		$this->get_alert('删除成功');
    	};
    }
    public function ajax_show(){
    	$this->ajax_get('proflie','show_m');
    }
    
    public function left(){//默认左列表
    	$left = array(
    		array('sort'=>'Proflie','name'=>'公司信息','value'=>'proflie_list'),
    		array('sort'=>'News','name'=>'新闻管理','value'=>'news_list'),
    		array('sort'=>'Info','name'=>'单页管理','value'=>'info_list'),
    		array('sort'=>'Info','name'=>'新增单页','value'=>'add')
    	);
     	$this->assign('user',$_SESSION['User']);
    	$this->assign('sort',$sort);
    	$this->assign('left',$left);
    	$this->display('Index:left');
    }
}
?>